package com.peng.multimodule;

import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.util.Log;
import android.view.View;
import android.widget.Button;

import com.alibaba.android.arouter.facade.Postcard;
import com.alibaba.android.arouter.facade.callback.NavigationCallback;
import com.alibaba.android.arouter.launcher.ARouter;


public class MainActivity extends AppCompatActivity {

    private static final String TAG = "TestActivity";

    private Button skip;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);


        skip = findViewById(R.id.skip);
        skip.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {


                String userName = ModuleRouteService.getUserName("userId");
//                String userName = ((IChatModuleService) ARouter.getInstance()
//                        .build("/chat_module/ChatModuleService")
//                        .navigation())
//                        .getUserName("userid");
//                Toast.makeText(MainActivity.this, userName, Toast.LENGTH_SHORT).show();
//
                IChatModuleService chatModuleService = (IChatModuleService) ARouter.getInstance()
                        .build("/chatModule/ChatModuleService")
                        .navigation();
//
//                Log.d(TAG, "onClick: chatModuleService-->" + chatModuleService);

//                String userName = chatModuleService.getUserName("userId");

                Log.d(TAG, "onClick: " + userName);
                ARouter.getInstance().build("/test_module/com/TestActivity").navigation(MainActivity.this, new NavigationCallback() {

                    @Override
                    public void onFound(Postcard postcard) {
                        Log.d(TAG, "onFound: ");
                    }

                    @Override
                    public void onLost(Postcard postcard) {
                        Log.d(TAG, "onLost: ");
                    }

                    @Override
                    public void onArrival(Postcard postcard) {
                        Log.d(TAG, "onArrival: ");
                    }

                    @Override
                    public void onInterrupt(Postcard postcard) {
                        Log.d(TAG, "onInterrupt: ");
                    }
                });
            }
        });
    }
}
